import moment from "moment";

const filters = {
  auditStatus (value) {
    if (value) return "已审核";
    return "未审核";
  },
  isChargeFree (value) {
    if (value) return value;
    return "未收取费用";
  },
  isEmpty (value) {
    if (value) return value;
    return "无信息";
  },
  contentStatus (value) {
    if (value) return value;
    return "";
  },
  toUtcTime (val) {
    if (val) {
      let res = new Date(val);
      return  moment(res).format("YYYY-MM-DD hh:mm:ss");
    }
    return val;
  },
  toUtcTime2 (val) {
    if (val) {
      let res = new Date(val);
      return moment(res).format("YYYY-MM-DD");
    }
    return val;
  },
  toJsonParse (val) {
    try {
      return JSON.parse(val);
    } catch (e) {
      return val;
    }
  },
  address (val) {
    try {
      if(val.hasOwnProperty("address")) return val.address;
      return val;
    } catch (e) {
      return val;
    }
  },
  translate (value) {
    switch (value) {
      case "activityAddress":
        return "活动地址";
      case "activityAuditStatus":
        return "活动审核状态";
      case "activityCreatedate":
        return "活动创建时间";
      case "activityDatetime":
        return "活动日期";
      case "activityDisc":
        return "活动内容";
      case "activityEndDatetime":
        return "活动截至时间";
      case "activityId":
        return "活动ID";
      case "activityIsfree":
        return "活动收费情况";
      case "activityLength":
        return "活动时长";
      case "activityMoney":
        return "活动费用";
      case "activityName":
        return "活动名称";
      case "activityRecruitPeople":
        return "活动预招募人数";
      case "activityRecruitedPeople":
        return "活动已招募人数";
      case "activityStatus":
        return "活动状态";
      case "activityType":
        return "活动类型";
      case "communityId":
        return "社团ID";
      case "communityName":
        return "社团名称";
      case "cover":
        return "封面";
      case "imagePath":
        return "封面地址";
      case "managerEntity":
        return "管理员信息";
      case "managerId":
        return "管理员ID";
      case "managerType":
        return "管理员类型";
      case "modifyDisc":
        return "修改描述";
      case "reason":
        return "驳回原因";
      case "recruitStatus":
        return "招募状态";
      case "serveTime":
        return "服务时长";
      case "tags":
        return "活动标志";
      case "volunteerEntity":
        return "志愿者信息";
      case "volunteerId":
        return "志愿者ID";
      default:
        return value;
    }
  },
};
export default filters;
